{
  LW Color Space -- LightWave Color Space

  Based on lwcolorspace.h which is:
  Copyright 2003, NewTek, Inc.
}

{
  Copyright 2012, Jameel Halabi

  This unit is part of the BlaiseWave wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}

unit LW_ColorSpace;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;

const
  LWCOLORSPACEFUNCS_GLOBAL = 'LWColorSpace';

  LW_COLORSPACE_VIEWER          =  'ColorSpaceViewer'        ;
  LW_COLORSPACE_SURFACE_COLOR   =  'ColorSpaceSurfaceColor'  ;
  LW_COLORSPACE_LIGHT_COLOR     =  'ColorSpaceLightColor'    ;
  LW_COLORSPACE_PALETTE_FILES   =  'ColorSpacePaletteFiles'  ;
  LW_COLORSPACE_8BIT_FILES      =  'ColorSpace8BitFiles'     ;
  LW_COLORSPACE_FLOAT_FILES     =  'ColorSpaceFloatFiles'    ;
  LW_COLORSPACE_ALPHA           =  'ColorSpaceAlpha'         ;
  LW_COLORSPACE_OUTPUT          =  'ColorSpaceOutput'        ;
  LW_COLORSPACE_OUTPUT_ALPHA    =  'ColorSpaceOutputAlpha'   ;
  LW_COLORSPACE_AUTO_SENSE      =  'ColorSpaceAutoSense'     ;
  LW_COLORSPACE_CORRECT_OPENGL  =  'ColorSpaceCorrectOpenGL' ;
  LW_COLORSPACE_AFFECT_PICKER   =  'ColorSpaceAffectPicker'  ;
  LW_COLORSPACE_8BIT_TO_FLOAT   =  'ColorSpace8BitToFloat'   ;

  // enum LWCOLORSPACE
  lwcs_linear  = 0 ;               // !< LightWave linear color space.
  lwcs_sRGB    = 1 ;               // !< Standard RGB color space.
  lwcs_rec709  = 2 ;               // !< Recommendation BT.709, HDTV.
  lwcs_cineon  = 3 ;               // !< Eastman Kodak Co.
  lwcs_ciexyz  = 4 ;               // !< CIE XYZ.
  lwcs_sizeof  = 5 ;

  // LWCOLORSPACETYPES
  lwcst_viewer         = 0 ;     // !< Viewer color space.
  lwcst_surface_color  = 1 ;     // !< Surface       color space.
  lwcst_palette_files  = 2 ;     // !< Palette files color space.
  lwcst_8bit_files     = 3 ;     // !< 8 bit   files color space.
  lwcst_float_files    = 4 ;     // !< Float   files color space.
  lwcst_alpha_files    = 5 ;     // !< Alpha   files color space.
  lwcst_output         = 6 ;     // !< Output  files color space.
  lwcst_output_alpha   = 7 ;     // !< Alpha   files color space.
  lwcst_light_color    = 8 ;     // !< Light         color space.
  lwcst_sizeof         = 9 ;

  // LWCOLORSPACECONVERSION
  lwcsc_colorspaceToLinear = 0 ;   // !< Convert from non-linear to linear.
  lwcsc_linearToColorspace = 1 ;   // !< Convert from linear to non-linear.
  lwcsc_sizeof             = 2 ;

  // LWCOLORSPACELAYER
  lwcsl_RGB    = 0 ;                 // !< RGB   Channel.
  lwcsl_Alpha  = 1 ;                 // !< Alpha Channel.
  lwcsl_sizeof = 2 ;

type

  { PLWImageLookup

  Is a forward reference to the internal lw instance structure ( defined internally ).
  This is used instead of a void * pointer. }

  PPLWImageLookup = ^PLWImageLookup;
  PLWImageLookup = ^TLWImageLookup;
  TLWImageLookup = record end;

  // !< Conversion function prototype.
  TLWPIXELCONVERSIONRGB = procedure
                          (      LwImgLookup : PLWImageLookup ;
                                 From        : PSingle        ;
                                 To_         : PSingle        );

  // !< Conversion function prototype.
  TLWPIXELCONVERSIONALPHA = procedure
                            (      LwImgLookup : PLWImageLookup ;
                                   From        : PSingle        ;
                                   To_         : PSingle        );

  { Color space functions.

    Color spaces file references are save in the scene file if they are used,
    in the viewer, color space file defaults or in a LWO from the image viewer. }

  TLWColorSpaceFuncs = record

    {  These function are used to get the color space of a
        loaded converter or load one from the disk. }

    // Originally this returned LWCOLORSPACE
    NameToColorSpace       : function
                             (      ColorSpaceName : PChar ) : Integer ; // !< Color space name.
    LoadPixelLookupTable   : function
                             (      Filename       : PChar ) : Integer ; // !< File name.

    //  These functions are used to get the pixel conversion functions.

    // Originally this returned LWPIXELCONVERSIONRGB and  LWPIXELCONVERSIONALPHA
     GetPixelConversionRGB    : function
                                (      LWColorSpace           : Integer ;
                                       LWColorSpaceConversion : Integer ;
                                       ImgLookup              : PPLWImageLookup ) : PInteger;
     GetPixelConversionAlpha  : function
                                (      LWColorSpace           : Integer ;
                                       LWColorSpaceConversion : Integer ;
                                       ImgLookup              : PPLWImageLookup ) : PInteger;

    //  These functions are used to get color space names and file names, based on type.
    // !< Gets the name of the current color space of the type selected.
    ColorSpaceName : function
                     (      LWColorSpaceTypes : Integer ) : PChar ; // const
    // !< Gets the file of the current color space of the type selected.
    ColorSpaceFile : function
                     (      LWColorSpaceTypes : Integer  ) : PChar; // const

    //  These functions are used in pop-ups.

    // !< Gets the number of loaded color spaces in the layer.
    NumberOfColorSpaces : function
                          (      LWColorSpaceLayer  : Integer ) : Integer ;

    // !< Gets the name of the color space in the layer.
    NameOfColorSpaces   : function
                          (       LWColorSpaceLayer : Integer ;
                                  ColorSpace        : Integer ) : PChar ; // const

    // Originally this returned LWCOLORSPACE
    // !< Used to convert from indexes of pop-ups to color spaces.
    IndexToColorSpace   : function
                          (      LWColorSpaceLayer : Integer ;
                                 LWColorSpace      : Integer ) : Integer ;
    ColorSpaceToIndex   : function
                          (      LWColorSpaceLayer : Integer ;
                                 LWColorSpace      : Integer ) : Integer;

    //  This functions is to change the currently selected color space.
    SetColorSpace : function
                    (      LWColorSpaceTypes : Integer ;
                           LWColorSpace      : Integer ) : Integer;

  end;
implementation

end.

